<div class="wrap" id="profile-page">
<h2>
<?php
switch ($_GET['action']) {
    case 'edit_student':
        echo _e('Edit Student');
        break;
    default:
        echo _e('Edit Student');
        break;
}

?></h2>
<?php
if ('edit_student' == $_GET['action']) {
    $student_no = $_GET['student_no'];
    $bPower = true;
} else {
    $id = null;
}
$info = getStudentInfo($student_no);
$form = initForm();
echo $form->start();

?>
<div id="ajax-response"></div>
<h3>
<?php echo _e('Student Info');

?>
</h3>
<table class="form-table">
<?php
$elements = array(
    array("label" => array("for" => "student_no", "name" => _e("Student No")),
        "form" => array("type" => "text", "options" => array("id" => "student_no", "name" => "student_no", "value" => $info['student_no'], "disabled" => true))),
    array("label" => array("for" => "student_name", "name" => _e("Student Name")),
        "form" => array("type" => "text", "options" => array("id" => "student_name", "name" => "student_name", "value" => $info['student_name']))),
    array("label" => array("for" => "ic_card_num", "name" => _e("IC Card Number")),
        "form" => array("type" => "text", "options" => array("id" => "ic_card_num", "name" => "ic_card_num", "value" => $info['ic_card_num'], "disabled" => true)))
    );
foreach($elements AS $element) {
    if (isset($element) && is_array($element)) {
        echo showFormRow($form, $element);
    } else {
        zeus_do_nothing();
    }
}

?>
</table>
<?php
$power = (isset($bPower))?true:false;
if ($power) {
    // Output html
    $html[] = "<h3>";
    $html[] = _e("Class Info");
    $html[] = "</h3>";
    $html[] = "<table class='form-table'>";
    $html[] = "<tr class='form-field'>";
    $html[] = "<th scope='row'>";
    $html[] = "<label for='role'>";
    $html[] = _e("Sex");
    $html[] = "</label></th><td>";
    // Get all sex
    $options = getAllSex();;
    $sex = array("property" => array("name" => "sex_id"),
        "options" => $options,
        "current" => $info['sex_id']);
    $html[] = $form->addSelect($sex['property'], $sex['options'], $sex['current']);
    $html[] = "</td></tr></table>";
    $html[] = "<table class='form-table'>";
    $html[] = "<tr class='form-field'>";
    $html[] = "<th scope='row'>";
    $html[] = "<label for='role'>";
    $html[] = _e("Class Name");
    $html[] = "</label></th><td>";
    // Get all role
    $myclass = unserialize($info['myclass_id']);
    $termIndex = getTermIndex();
    $firstentry = _e('Please Select Class...');
    $options = getCurrentClass();
    $options[0] = $firstentry;
    $myclass = array("property" => array("name" => "myclass_id"),
        "options" => $options,
        "current" => $myclass[$termIndex]);
    $html[] = $form->addSelect($myclass['property'], $myclass['options'], $myclass['current']);
    $html[] = "</td></tr></table>";
    $html[] = "<table class='form-table'>";
    $html[] = "<tr class='form-field'>";
    $html[] = "<th scope='row'>";
    $html[] = "<label for='role'>";
    $html[] = _e("Status");
    $html[] = "</label></th><td>";
    // Get user status
    $options = array(0 => _e("Locked"), 1 => _e("Actived"));
    $enable = array("property" => array("name" => "is_enable"),
        "options" => $options,
        "current" => $info['is_enable']);
    $html[] = $form->addSelect($enable['property'], $enable['options'], $enable['current']);
    $html[] = "</td></tr></table>";
    echo implode("", $html);
} else {
    zeus_do_nothing();
}

?>
<h3>
<?php echo _e('Contact Info');

?>
</h3>
<table class="form-table">
<?php
$elements = array(
    array("label" => array("for" => "email", "name" => _e("Email")),
        "form" => array("type" => "text", "options" => array("id" => "email", "name" => "email", "value" => $info['email']))),
    array("label" => array("for" => "im", "name" => _e("IM")),
        "form" => array("type" => "text", "options" => array("id" => "im", "name" => "im", "value" => $info['im']))),
    array("label" => array("for" => "homepage", "name" => _e("Homepage")),
        "form" => array("type" => "text", "options" => array("id" => "homepage", "name" => "homepage", "value" => $info['homepage']))),
    array("label" => array("for" => "cell_phone", "name" => _e("Cell Phone")),
        "form" => array("type" => "text", "options" => array("id" => "cell_phone", "name" => "cell_phone", "value" => $info['cell_phone']))),
    array("label" => array("for" => "home_phone", "name" => _e("Home Phone")),
        "form" => array("type" => "text", "options" => array("id" => "home_phone", "name" => "home_phone", "value" => $info['home_phone']))),
    array("label" => array("for" => "address", "name" => _e("Address")),
        "form" => array("type" => "text", "options" => array("id" => "address", "name" => "address", "value" => $info['address'])))
    );
foreach($elements AS $element) {
    if (isset($element) && is_array($element)) {
        echo showFormRow($form, $element);
    } else {
        zeus_do_nothing();
    }
}

?>
</table>
<p class="submit">
<?php
echo $form->addElement("submit", array("name" => "sv-form", "id" => "wp-submit", "value" => _e("Edit Student")));

?>
</p>
<?php
echo $form->end();
$form = null;
unset($form);

?>
</div>